﻿using MediatR;
using SheepStorage.API.Application.Command.DepartmentCommand;
using SheepStorage.API.Baseclass;
using SheepStorage.Domain.Entity;
using SheepStorage.Service.Interface;

namespace SheepStorage.API.Application.CommandHandlers.DepartmentHandler
{
    public class DepartmentSlectCommandHandler : IRequestHandler<DepartSelectCommand, Results<List<Department>>>
    {

        private readonly IDepartmentService departmentService;

        public DepartmentSlectCommandHandler(IDepartmentService departmentService)
        {
            this.departmentService = departmentService;
        }
        public async Task<Results<List<Department>>> Handle(DepartSelectCommand request, CancellationToken cancellationToken)
        {
            return Results<List<Department>>.DataResult(await departmentService.GetDepartment());
        }
    }
}
